import random
w=random.randint(0,1)
a=0
b=0
c=0
d=0
e=0
f=0
g=0
h=0
i=0
w_1=0
w_2=0
def sanziqi():
    print(a,b,c)
    print(d,e,f)
    print(g,h,i)
while w_1==0 and w_2==0:
    sanziqi()
    while w==0:
        z=0
        while z<1:
            w_11=int(input("1,2,3,4,5,6,7,8,9"))
            while w_11==1 and a==0:
                a=1
                z=1
            while w_11==2 and b==0:
                b=1
                z=1
            while w_11==3 and c==0:
                z=1
                c=1  
            while w_11==4 and d==0:
                z=1
                d=1
            while w_11==5 and e==0:
                z=1
                e=1
            while w_11==6 and f==0:
                z=1
                f=1
            while w_11==7 and g==0:
                z=1
                g=1
            while w_11==8 and h==0:
                z=1
                h=1
            while w_11==9 and i==0:
                z=1
                i=1
        z=0
        w=1
    sanziqi()
    while w==1:
        z=0
        while z<1:
            w_11=int(input("1,2,3,4,5,6,7,8,9"))
            while w_11==1 and a==0:
                a=2
                z=1
            while w_11==2 and b==0:
                b=2
                z=1
            while w_11==3 and c==0:
                z=1
                c=2  
            while w_11==4 and d==0:
                z=1
                d=2
            while w_11==5 and e==0:
                z=1
                e=2
            while w_11==6 and f==0:
                z=1
                f=2
            while w_11==7 and g==0:
                z=1
                g=2
            while w_11==8 and h==0:
                z=1
                h=2
            while w_11==9 and i==0:
                z=1
                i=2
        z=0
        w=0
    if a==1:
        w_1=1
    if a==2:
        w_2=1 